spacepaste

  1.  
  2. SRC = $(wildcard *.c)
  3. OBJS = $(SRC:%.c=%.o)
  4. HEADERS = $(SRC:%.c=%.h)
  5. PRG = test
  6. OBJ = test.o
  7. MCU_TARGET = atmega168
  8. OPTIMIZE = -O2
  9. DEFS =
  10. LIBS = -lm
  11. ASRC = i2cmaster.S
  12. # You should not have to change anything below here.
  13. CC = avr-gcc
  14. CXX = avr-g++
  15. # Override is only needed by avr-lib build system.
  16. override CFLAGS = -g -Wextra -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS) -I/usr/avr/include/avr/
  17. override CXXFLAGS = -g -Wextra -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS)
  18. override LDFLAGS = -Wl,-Map,$(PRG).map
  19. OBJCOPY = avr-objcopy
  20. OBJDUMP = avr-objdump
  21. all: $(PRG).elf lst text eeprom
  22. $(PRG).elf: $(SRC) $(HEADERS)
  23. $(CC) $(CFLAGS) $(LDFLAGS) -o $(PRG).elf $(SRC) $(LIBS)
  24. clean:
  25. rm -rf *.o $(PRG).elf *.eps *.png *.pdf *.bak
  26. rm -rf *.lst *.map $(EXTRA_CLEAN_FILES)
  27. flash:
  28. avrdude -c avrispmkII -P usb -p $(MCU_TARGET) -e -U flash:w:$(PRG).hex
  29. fuse:
  30. avrdude -c avrispmkII -P usb -p $(MCU_TARGET) -U lfuse:w:0xf7:m -U hfuse:w:0xdf:m -U efuse:w:0xf9:m
  31. lst: $(PRG).lst
  32. %.lst: %.elf
  33. $(OBJDUMP) -h -S $< > $@
  34. # Rules for building the .text rom images
  35. text: hex bin srec
  36. hex: $(PRG).hex
  37. bin: $(PRG).bin
  38. srec: $(PRG).srec
  39. %.hex: %.elf
  40. $(OBJCOPY) -j .text -j .data -O ihex $< $@
  41. %.srec: %.elf
  42. $(OBJCOPY) -j .text -j .data -O srec $< $@
  43. %.bin: %.elf
  44. $(OBJCOPY) -j .text -j .data -O binary $< $@
  45. # Rules for building the .eeprom rom images
  46. eeprom: ehex ebin esrec
  47. ehex: $(PRG)_eeprom.hex
  48. ebin: $(PRG)_eeprom.bin
  49. esrec: $(PRG)_eeprom.srec
  50. %_eeprom.hex: %.elf
  51. $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@
  52. %_eeprom.srec: %.elf
  53. $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O srec $< $@
  54. %_eeprom.bin: %.elf
  55. $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O binary $< $@
  56. # Every thing below here is used by avr-libc's build system and can be ignored
  57. # by the casual user.
  58. FIG2DEV = fig2dev
  59. EXTRA_CLEAN_FILES = *.hex *.bin *.srec
  60. dox: eps png pdf
  61. eps: $(PRG).eps
  62. png: $(PRG).png
  63. pdf: $(PRG).pdf
  64. %.eps: %.fig
  65. $(FIG2DEV) -L eps $< $@
  66. %.pdf: %.fig
  67. $(FIG2DEV) -L pdf $< $@
  68. %.png: %.fig
  69. $(FIG2DEV) -L png $< $@
  70.